home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / gui140.zip / OLDGUI.BAS < prev    next >
BASIC Source File  |  1997-06-28  |  8KB  |  349 lines

  1. ' Graphical User Interface V. 1.0
  2.  
  3. ' Written by Tika Carr
  4. ' Released into the Public Domain on November 4, 1995
  5.  
  6. ' This is I think the very first official release. This is NOT part
  7. ' of the library! Its just an example to show how this project developed.
  8. ' Maybe some can get some ideas out of this to add on to the other one.
  9.  
  10. ' To create the GUI library, you MUST use GUI140.BAS, NOT THIS ONE!
  11.   
  12. DECLARE SUB Mouse2 ()
  13. DECLARE SUB Overlay (x1%, y1%, x2%, y2%, Klr%, OFlg%)
  14. DECLARE SUB OvrWin (x1%, y1%, x2%, y2%, Klr%)
  15. DECLARE SUB Mouse ()
  16. DECLARE SUB CircleBtn ()
  17. DECLARE SUB VScreen (x1%, y1%, x2%, y2%, Bkgn%)
  18. DECLARE SUB startmouse ()
  19. DECLARE SUB showmouse ()
  20. DECLARE SUB getmousecord (btn%, M3%, M4%)
  21. DECLARE SUB hidemouse ()
  22. DECLARE SUB MakeButton (P$, XL%, KKr%, KKh%)
  23. DECLARE SUB ButtonDraw ()
  24. DECLARE SUB gprint (S$, x%, y%, Klr%)
  25.   
  26. ' This uses VGA graphics mode 12:  640 x 480/16 color, 80 x 60 text area
  27.   
  28. DEFINT A-Z
  29. '$INCLUDE: 'QB.BI'
  30.   
  31. TYPE COORD
  32.  bx1 AS INTEGER
  33.  bx2 AS INTEGER
  34.  Flag AS INTEGER
  35. END TYPE
  36.   
  37. DIM SHARED Inregs AS RegType, Outregs AS RegType
  38. DIM SHARED Buttons(1 TO 9) AS COORD
  39. COMMON SHARED BN, Flg, Bkgn, VW, CFlag, PI, x, y, btn
  40. PI = 3.141593
  41.   
  42.   
  43. SCREEN 12: CLS
  44. WIDTH 80, 60
  45.   
  46. 'Possible Palettes:
  47.   
  48. 'PALETTE 0, (65536 * 47 + 256 * 47 + 47) ' Grey Background
  49. PALETTE 0, (65536 * 45 + 256 * 45 + 63)  ' Baby Pink Background
  50. 'PALETTE 0, (65536 * 57 + 256 * 57 + 57)  ' White Background
  51. 'PALETTE 0, (65536 * 50 + 256 * 47 + 0)   ' Cyan Background
  52.   
  53. 'Help Button Hide/Display default
  54.   
  55. HideHelp = 0: CFlag = 1
  56.   
  57. 'Circle Button for Help - 0 is 'Display (don't hide)
  58.   
  59. IF HideHelp = 0 THEN
  60.  CALL CircleBtn
  61. END IF
  62.   
  63. 'Syntax: MakeButton(Title, XLocation(LOCATE), Text Color, Highlight Color)
  64.   
  65. 'NOTE: Flg=1 is button is "out"; Flg=0 is button is "in"
  66.   
  67. BN = 2: Flg = 1: CALL MakeButton("File", 8, 8, 1)
  68.   
  69. ' NOTE: Bkgn MUST be LESS than 8 (Bkgn values must be 0-7)
  70. '       Other combinations may or may not work.  Test values before
  71. '       using them.  GPRINT uses a BIOS video write to put text on screen.
  72.   
  73. 'Syntax: VScreen(x1, y1, x2, y2, Bkgn)
  74.   
  75. CALL VScreen(0, 30, 639, 479, 7)
  76. VW = 1: CALL gprint("Hello", 45, 23, 6)  'VW is view window is "on" for GPRINT
  77.   
  78. startmouse
  79. showmouse
  80.   
  81. 'Start Input
  82.   
  83. Inloop:
  84.   
  85. Mouse
  86. IF btn = 2 THEN GOTO Done
  87.   
  88. 'Check Mouse Coordinates
  89.   
  90. 'Help Button
  91.   
  92. IF x < 21 AND y < 21 THEN
  93.  x1 = 314: y1 = 153: x2 = 554: y2 = 394: Klr = 3
  94.  ga = 4 + INT(((x2 - x1 + 1) * (1) + 7) / 8) * 4 * ((y2 - y1) + 1)
  95.  DIM OvScn(1 TO ga) AS INTEGER
  96.  GET (x1, y1)-(x2, y2), OvScn
  97.  CFlag = 0
  98.  CALL CircleBtn
  99.  CALL OvrWin(x1, y1, x2, y2, Klr)
  100.  CALL gprint("This is the Help Screen.", 42, 23, 2)
  101.  CALL gprint("Click Mouse to Continue.", 42, 25, 13)
  102.  
  103.  Mouse
  104.  hidemouse
  105.  PUT (x1, y1), OvScn, PSET
  106.  ERASE OvScn
  107.  showmouse
  108.  CFlag = 1
  109.  CALL CircleBtn
  110. END IF
  111.   
  112. ' File Menu Activated.
  113.   
  114. IF x >= 51 AND y >= 2 AND x <= 90 AND y <= 18 THEN
  115.  Flg = 0
  116.  ButtonDraw
  117.   
  118.  x1 = 32: y1 = 34: x2 = 115: y2 = 146: Klr = 3
  119.  ga = 4 + INT(((x2 - x1 + 1) * (1) + 7) / 8) * 4 * ((y2 - y1) + 1)
  120.  DIM OvScn(1 TO ga) AS INTEGER
  121.  GET (x1, y1)-(x2, y2), OvScn
  122.  VW = 1: OFlg = 1
  123.  CALL Overlay(x1, y1, x2, y2, Klr, OFlg)
  124.  CALL gprint("New", 5, 2, 13)
  125.  CALL gprint("Open", 5, 4, 13)
  126.  CALL gprint("Save", 5, 6, 13)
  127.  CALL gprint("Save As..", 5, 8, 13)
  128.  CALL gprint("Print", 5, 10, 13)
  129.  CALL gprint("Exit", 5, 12, 13)
  130.   
  131.  Mouse
  132.   
  133.  'Exit Option
  134.   
  135.  mx1 = 35: my1 = 123: mx2 = 112: my2 = 138: mKlr = 3: mOFlg = 0
  136.  IF x > mx1 AND x < mx2 AND y > my1 AND y < my2 THEN
  137.   hidemouse
  138.  CALL Overlay(mx1, my1, mx2, my2, mKlr, mOFlg)
  139.   CALL gprint("Exit", 5, 12, 1)
  140.   showmouse
  141.   Mouse2
  142.  IF x > mx1 AND x < mx2 AND y > my1 AND y < my2 THEN
  143.   END
  144.  ELSE
  145.  GOTO DDN
  146.  END IF
  147.  END IF
  148.   
  149.  'Print Option
  150.   
  151.  'The mx values are 16 less that that of the Exit option
  152.  '(8 pixels/row so since they are every other row, 8 * 2 = 16)
  153.   
  154.  mx1 = 35: my1 = 107: mx2 = 112: my2 = 122: mKlr = 3: mOFlg = 0
  155.  IF x > mx1 AND x < mx2 AND y > my1 AND y < my2 THEN
  156.   hidemouse
  157.  CALL Overlay(mx1, my1, mx2, my2, mKlr, mOFlg)
  158.   
  159.   'Note here we change gprint to reflect the Print option and its
  160.   'y coordinate location.
  161.   
  162.   CALL gprint("Print", 5, 10, 1)
  163.   showmouse
  164.   Mouse2
  165.  IF x > mx1 AND x < mx2 AND y > my1 AND y < my2 THEN
  166.   
  167.   'Action for Print Option goes here.
  168.   
  169.  ELSE
  170.  GOTO DDN
  171.  END IF
  172.  END IF
  173. DDN:
  174.   hidemouse
  175.   PUT (x1, y1), OvScn, PSET
  176.   showmouse
  177.   ERASE OvScn
  178.   
  179.   Flg = 1
  180.   ButtonDraw
  181.   
  182. END IF
  183.   
  184. GOTO Inloop
  185.   
  186. Done:
  187.   
  188. 'Pause Display and Wait for Keypress
  189. 'Pause$ = INPUT$(1)
  190.   
  191. hidemouse
  192.  
  193. SUB ButtonDraw
  194. hidemouse
  195. yb = Buttons(BN).bx2 - Buttons(BN).bx1
  196. IF Flg = 1 THEN k1 = 15: k2 = 8 ELSE k1 = 8: k2 = 15
  197. DRAW "C" + STR$(k1) + "BM" + STR$(Buttons(BN).bx1) + ",18U15R" + STR$(yb)
  198. DRAW "C" + STR$(k2) + "BM" + STR$(Buttons(BN).bx1) + ",18R" + STR$(yb) + "U15"
  199. showmouse
  200. END SUB
  201.  
  202. SUB CircleBtn
  203.   
  204. hidemouse
  205.  LINE (9, 0)-(11, 11), 0, BF
  206.  CIRCLE (10, 11), 10, 8
  207.  PAINT (10, 11), 12, 8
  208.  IF CFlag = 1 THEN c1 = 15: c2 = 8 ELSE c1 = 8: c2 = 15
  209.  CIRCLE (10, 11), 9, c1, 1, INT(PI + 1)
  210.  CIRCLE (10, 11), 9, c2, INT(PI + 1), .5
  211.   
  212.  VW = 0: CALL gprint("?", 1, 2, 3)  'Note: VW is view window ON/OFF; 0=OFF
  213.   
  214.  'NOTE: above colors for GPRINT: 2 is Yellow, 3 is White
  215.  '      for last number: GPRINT($, x, y, color)
  216.   
  217. showmouse
  218. END SUB
  219.  
  220. SUB getmousecord (btn%, M3%, M4%)
  221. Inregs.ax% = 3
  222. CALL INTERRUPT(&H33, Inregs, Outregs)
  223. M3% = Outregs.cx%
  224. M4% = Outregs.dx%
  225. btn% = Outregs.bx%
  226. END SUB
  227.  
  228. SUB gprint (S$, x, y, Klr)
  229. IF VW = 1 THEN y = y + 5
  230.   
  231. IF Klr < 10 THEN
  232.  Klr = Klr + 8
  233.  B = (Bkgn XOR Klr) - 8
  234. ELSE
  235.  B = Bkgn XOR Klr
  236. END IF
  237.   
  238. IF B < 10 THEN B$ = "&HF" + HEX$(B) ELSE B$ = "&HF" + HEX$(B)
  239. Inregs.bx% = VAL(B$)
  240. Inregs.cx% = 1
  241. AH$ = "9"
  242.   
  243. FOR count = 1 TO LEN(S$)
  244.  A$ = MID$(S$, count, 1)
  245.  AL$ = HEX$(ASC(A$))
  246.  Inregs.ax% = VAL("&H" + AH$ + AL$)
  247.  LOCATE y, x + count
  248.  CALL INTERRUPT(&H10, Inregs, Outregs)
  249. NEXT count
  250.   
  251. END SUB
  252.  
  253. SUB hidemouse
  254. Inregs.ax% = 2
  255. CALL INTERRUPT(&H33, Inregs, Outregs)
  256. END SUB
  257.  
  258. SUB MakeButton (P$, XL, KKr, KKh)
  259.   
  260. 'Highlight First Character
  261.   
  262. PH$ = LEFT$(P$, 1): PR$ = RIGHT$(P$, LEN(P$) - 1)
  263. COLOR KKh: LOCATE 2, XL: PRINT PH$;
  264. COLOR KKr: PRINT PR$
  265.   
  266. Buttons(BN).bx1 = (XL - 1) * 8 - 4
  267. Buttons(BN).bx2 = Buttons(BN).bx1 + (LEN(P$) * 8) + 6
  268.   
  269. LINE (Buttons(BN).bx1 - 1, 2)-(Buttons(BN).bx2 + 1, 19), 8, B
  270.   
  271. CALL ButtonDraw
  272.   
  273. END SUB
  274.  
  275. SUB Mouse
  276.   
  277. DO
  278.  getmousecord btn, x, y
  279.  LOCATE 59, 5
  280.  PRINT x, y, btn;
  281.   
  282. LOOP WHILE btn = 0
  283.   
  284. END SUB
  285.  
  286. SUB Mouse2
  287. DO
  288.  getmousecord btn, x, y
  289.  LOCATE 59, 5
  290.  PRINT x, y, btn;
  291.   
  292. LOOP WHILE btn <> 0
  293. DO
  294.  getmousecord btn, x, y
  295.  LOCATE 59, 5
  296.  PRINT x, y, btn;
  297.  
  298.  
  299. LOOP WHILE btn = 0
  300.   
  301. END SUB
  302.  
  303. SUB Overlay (x1, y1, x2, y2, Klr, OFlg)
  304.  IF OFlg = 1 THEN c1 = 15: c2 = 8 ELSE c1 = 8: c2 = 15
  305.  hidemouse
  306.  LINE (x1, y1)-(x2, y2), 8, B
  307.  PAINT (x1 + 1, y1 + 1), Klr, 8
  308.  DRAW "c" + STR$(c1) + "bm" + STR$(x1 + 1) + "," + STR$(y2 - 1) + "U" + STR$(y2 - y1 - 2) + "R" + STR$(x2 - x1 - 2)
  309.  DRAW "c" + STR$(c2) + "bm" + STR$(x1 + 1) + "," + STR$(y2 - 1) + "R" + STR$(x2 - x1 - 2) + "U" + STR$(y2 - y1 - 2)
  310.  showmouse
  311. END SUB
  312.  
  313. SUB OvrWin (x1, y1, x2, y2, Klr)
  314.   
  315. A = x1 + 1: B = y2 - 1: C = y2 - y1 - 2
  316. E = x1 + 9: F = y2 - 9: G = y2 - y1 - 18
  317.   
  318. LINE (x1, y1)-(x2, y2), 8, B
  319. PAINT (x1 + 10, y1 + 10), Klr, 8
  320.   
  321. LINE (x1 + 8, y1 + 9)-(x2 - 8, y2 - 8), 8, B
  322. PAINT (x1 + 10, y1 + 10), Klr, 8
  323.   
  324. DRAW "C15BM" + STR$(A) + "," + STR$(B) + "U" + STR$(C) + "R" + STR$(C)
  325. DRAW "C8BM" + STR$(A) + "," + STR$(B) + "R" + STR$(C - 1) + "U" + STR$(C - 1)
  326. DRAW "C8BM" + STR$(E) + "," + STR$(F) + "U" + STR$(G) + "R" + STR$(G)
  327. DRAW "C15BM" + STR$(E) + "," + STR$(F - 1) + "R" + STR$(G - 1) + "U" + STR$(G - 1)
  328.   
  329. END SUB
  330.  
  331. SUB showmouse
  332. Inregs.ax% = 1
  333. CALL INTERRUPT(&H33, Inregs, Outregs)
  334. END SUB
  335.  
  336. SUB startmouse
  337. Inregs.ax% = 0
  338. CALL INTERRUPT(&H33, Inregs, Outregs)
  339. MouseInitialize% = Outregs.ax%
  340. END SUB
  341.  
  342. SUB VScreen (x1, y1, x2, y2, Bkgn)
  343. LINE (x1, y1)-(x2, y2), 8, B
  344. PAINT (x1 + 1, y1 + 1), Bkgn, 8
  345. DRAW "c8bm" + STR$(x1 + 1) + "," + STR$(y2 - 1) + "u" + STR$(y2 - y1) + "r" + STR$(x2 - x1)
  346. DRAW "c15bm" + STR$(x1 + 1) + "," + STR$(y2 - 1) + "r" + STR$(x2 - x1 - 2) + "u" + STR$(y2 - y1)
  347. END SUB
  348.  
  349.